staticGuard = $staticGuard; } public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Changes ArrowFunction to be static when possible', [new CodeSample(<<<'CODE_SAMPLE' fn (): string => 'test'; CODE_SAMPLE , <<<'CODE_SAMPLE' static fn (): string => 'test'; CODE_SAMPLE )]); } /** * @return array> */ public function getNodeTypes() : array { return [ArrowFunction::class]; } /** * @param ArrowFunction $node */ public function refactor(Node $node) : ?Node { if (!$this->staticGuard->isLegal($node)) { return null; } $node->static = \true; return $node; } }